/**
 * A PrimHeapNode has a vertex which keeps track of where
 * it exists in the heap -- getData().getIndex()
 * 
 * @author Ken "David" McClain
 * @author Faiz
 * @author Aakanksha
 * @version 20 May 2011
 * 
 * Some of this code was borrowed and modified from Dr Chinn's MergesortHeapNode.java
 * Available at: http://faculty.washington.edu/dchinn/courses/11sp/tcss343/homework/hw2/start-code/MergesortHeapNode.java
 */
public class PrimHeapNode implements Comparable {
  
  /** The vertex this node represents. */
  public Vertex v;
  
  /** Constructor.
    * @param vert the vertex this node represents. */
  public PrimHeapNode(Vertex vert) {
    v = vert;
  }
  
  /**
   * Implements the compareTo method.
   * @param other the other PrimHeapNode object.
   * @return 0 if two objects are equal;
   *     less than zero if this object is smaller;
   *     greater than zero if this object is larger.
   * @exception ClassCastException if rhs is not a PrimHeapNode.
   */
  public int compareTo (Object other) {
    VertexInfo vi =     (VertexInfo) this.v.getData();
    VertexInfo otheri = (VertexInfo) ((PrimHeapNode) other).v.getData();
    
    // If this node's vertex's distance is less than the other node's vertex's distance
    if ( vi.getDist() < otheri.getDist()) {
      return -1;
      
    // If it is equal...
    } else if (vi.getDist() == otheri.getDist()) {
      return 0;
      
    } else {
      return 1;
    }
  }

}